#ifndef CUBOID_H
#define CUBOID_H
#define MAX_SIZE VOXEL_SIZE

#include "includes.h"
#include "rendermanager.h"
//axis-aligned bounding box

struct AABB
{
    vector3<float> start, end, center;

    AABB(vector3<float> _start, vector3<float> _end);
    bool hasContactedAABB(vector3<float> _start, vector3<float> _end);
    bool hasContactedAABB(AABB& box);
    bool hasContactedWorld();

    vector3<float> getCorrection(vector3<float> _start, vector3<float> _end);

    //implicit inline
    bool hasContactedVoxel(vector3<float> _coords){
        vector3<float> coords((int)_coords.x,(int)_coords.y,(int)_coords.z);
        return hasContactedAABB(coords,coords+vector3<float>(VOXEL_SIZE,VOXEL_SIZE,VOXEL_SIZE));
    }

    void translate(vector3<float> t){
        start+=t;
        end+=t;
        center+=t;
    }

    void scale(vector3<float> s){
        end -= start;
        end.x *=s.x;
        end.y *=s.y;
        end.z *=s.z;
        end += start;
    }

    void add(vector3<float> v){

        start-=v;
        end+=v;
    }

};

#endif // CUBOID_H
